package com.fastCms.business.bim.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fastCms.business.frame.constant.CommonConst;
import com.fastCms.business.bim.pojo.entity.DeviceGroupRel;
import com.fastCms.business.bim.daos.DeviceGroupRelMapper;
import com.fastCms.business.bim.service.DeviceGroupRelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 设备组关联 服务实现类
 * </p>
 *
 * @author liusq
 * @since 2021-07-14
 */
@Service
public class DeviceGroupRelServiceImpl extends ServiceImpl<DeviceGroupRelMapper, DeviceGroupRel> implements DeviceGroupRelService {

    @Override
    public DeviceGroupRel findByGroupIdAndDeviceId(Integer groupId, Integer deviceId) {
        QueryWrapper<DeviceGroupRel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        queryWrapper.eq("group_id", groupId);
        queryWrapper.eq("device_id", deviceId);
        return getOne(queryWrapper);
    }
}
